class Solution(object):
    def fractionToDecimal(self, numerator, denominator):
        if numerator * denominator < 0:
            s = '-'
        else:
            s = ''
        yushu_dict = {}
        numerator = abs(numerator)
        denominator = abs(denominator)
        shang = numerator // denominator
        yushu = numerator % denominator
        s += str(shang)
        if yushu == 0:
            return s
        s += '.'
        index = len(s)
        flag = True
        while yushu > 0:
            if yushu not in yushu_dict:
                yushu_dict[yushu] = index
                yushu = yushu * 10
                shang = yushu // denominator
                s += str(shang)
                yushu = yushu % denominator
                index += 1
            else:
                flag = False
                break
        if flag:
            return s
        else:
            return s[:yushu_dict[yushu]] + '(' + s[yushu_dict[yushu]:] + ')'

data = Solution()
numerator = 4
denominator = 333
print(data.fractionToDecimal(numerator, denominator))
